package com.wu.constant.Enum;

import com.wu.common.convertion.exception.ServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author Cousin
 * @date 2025/1/10
 * @Description 用户状态枚举
 */
@AllArgsConstructor
@Getter
public enum UserStatusEnum {
    NORMAL(0, "normal","正常"),
    MUTED(1,"muted" ,"禁言"),
    BANNED(2,"banned" ,"封号");
    private final Integer code;
    private final String status;
    private final String desc;
    public static Integer getCodeByStatus(String name) {
        for (UserStatusEnum e : UserStatusEnum.values()) {
            if (e.getStatus().equals(name)) {
                return e.getCode();
            }
        }
        throw new ServiceException("Invalid status");
    }
}
